<?php
// go 语言安装

Go并发机制：
https://studygolang.com/articles/11322?fr=sidebar

go语言之并发：
https://www.cnblogs.com/cyzsoho/p/4849874.html

《Go in action》读后记录：Go的并发与并行：
https://www.cnblogs.com/QG-whz/p/7616547.html




beego文档：
https://beego.me/docs/intro/
https://www.kancloud.cn/hello123/beego/126104
安装：
https://beego.me/quickstart
https://www.cnblogs.com/tinywan/p/8492137.html

视频教程：
http://edu.51cto.com/center/course/lesson/index?id=25452
http://edu.51cto.com/center/course/lesson/index?id=24586

SMART原则:
https://wiki.mbalib.com/wiki/SMART%E5%8E%9F%E5%88%99

git 学习：
    https://learngitbranching.js.org/?demo

文件按行读取：
https://blog.csdn.net/u010003835/article/details/51883069


golang判断字符串出现的位置及是否包含：
https://studygolang.com/articles/15886?fr=sidebar

Go语言 go程释放（退出/销毁）：
https://blog.csdn.net/weixin_42117918/article/details/82318508

时间戳：
https://blog.csdn.net/skh2015java/article/details/70051512
golang的time包，秒、毫秒、纳秒时间戳输出：
https://blog.csdn.net/mirage003/article/details/80822608
https://blog.csdn.net/liangguangchuan/article/details/51658633

时间包：
https://blog.csdn.net/zhonglinzhang/article/details/45913147

【链接】golang监听端口
https://studygolang.com/articles/3639

go get github.com/gomodule/redigo/redis

https://github.com/bradfitz/gomemcache


判断变量类型：
    fmt.Println("type:", reflect.TypeOf(content))


golang学习笔记13 Golang 类型转换整理 go语言string、int、int64、float64、complex 互相转换
https://studygolang.com/articles/13139

字符串分割：
https://studygolang.com/articles/5049


markdown 操作：
  https://blog.csdn.net/qq_20011607/article/details/81370236
  
Sublime Text怎么用Markdown：
  https://www.jianshu.com/p/eaadb8879308


  
Preferences -> Package Settings -> Markdown Editing -> Markdown GFM Setting - User
Markdown Editing视图左边会空出一块区域
   "draw_centered": false
设置视图显示行号
   "line_numbers": true
高亮行号：
"highlight_line": false,

   设置宽度撑满屏幕
   "word_wrap": false

Go语言反射规则:
  https://studygolang.com/articles/17406


go是面向对象语言吗？:
https://blog.csdn.net/li_101357/article/details/80205005

安装：
    go get github.com/astaxie/beego
    go get github.com/beego/bee
go get github.com/kardianos/govendor

govendor init
govendor add -tree github.com/astaxie/beego
govendor add -tree github.com/nfnt/resize
govendor add -tree github.com/skip2/go-qrcode
govendor add -tree github.com/shiena/ansicolor



go get github.com/smartystreets/goconvey

go get github.com/gopherjs/gopherjs

Golang包管理工具 - govendor:
https://blog.csdn.net/cyberspecter/article/details/83345760

cd $GOPATH/src
mkdir -p golang.org/x/
cd  golang.org/x/
git clone https://github.com/golang/crypto.git


glide mirror set golang.org/x/crypto github.com/golang/crypto


golang 不翻墙安装golang.org/x/net:
https://studygolang.com/articles/10797
mkdir -p $GOPATH/src/golang.org/x/
cd $GOPATH/src/golang.org/x/
git clone https://github.com/golang/net.git
go install net


https://github.com/golang/text

1.golang.org\x\net\context，对应的可访问链接：https://github.com/golang/net，里面包含context，dns，http2等一系列资源

2.golang.org/x/text/secure/bidirule，对应的可访问链接：https://github.com/golang/text，里面包含cmd，currency，secure等一系列资源

3.google.golang.org/grpc，对应的可访问链接：https://github.com/grpc/grpc-go，里面包含connectivity，grpclb，grpclog等一系列资源

4.google.golang.org/genproto，对应的可访问链接：https://github.com/google/go-genproto，里面包含googleapis，protobuf等一系列资源



export GOROOT=/usr/local/go
export GOPATH=/alidata/www/limicode/go
export PATH=$PATH:$GOROOT/bin:/alidata/www/limicode/go/bin

环境变量：
默认：
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin/
修改：
export GOPATH=/alidata/www/limicode/go
export PATH=$PATH:$GOPATH/bin/




export GOROOT=/usr/local/go
export GOPATH=/alidata/golang:/alidata/www/limicode/go
export PATH=$PATH:$GOROOT/bin:/alidata/golang/bin:/alidata/www/limicode/go/bin





#!/bin/bash
set -e
cd $GOPATH/src/service-go && go build


src="$GOPATH/src/service-go/service-go " 



/usr/local/nginx/sbin/nginx -t

server {
        server_name service-go.limiketang.com;
        listen 80;
        #listen 443 ssl;
 
        charset utf-8;
 
        access_log /mnt/log/nginx/service-go.limiketang.com-access.log;
        error_log /mnt/log/nginx/service-go.limiketang.com-error.log;
 
        error_page 404 /404.html;
        error_page 500 502 503 504 /500.html;
 
        location / {
                try_files /_not_exists_ @backend;
        }
 
        location @backend {
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header Host            $http_host;
 
                proxy_pass http://127.0.0.1:15001;
        }
}


nohup  /alidata/www/limicode/go/src/service-go/service-go 2> /dev/null &

新项目：
cd $GOPATH/src
bee new hello
cd hello
bee run

图片压缩加水印：

http://www.voidcn.com/code/p-zshmjojh-p.html

README.md


    //cmd_thumbnail(newImg)
    abc := resize.Resize(2048, 0, newImg, resize.Lanczos3)

    canvas := resize.Thumbnail(300, 300, abc, resize.Lanczos3)
    file_out, err := os.Create("./aaa.jpg")
    if err != nil {
        log.Fatal(err)
    }
    defer file_out.Close()

    jpeg.Encode(file_out, canvas, &jpeg.Options{30})



查看版本：
bee version


generate 代码生成：
    bee generate controller Index
    bee generate controller Base
bee generate view
bee generate model school_term [-fields="name:type"
bee generate appcode -tables=school_term -driver=mysql -conn="root:@tcp(101.201.152.97:6379)/yun_platform" -level=3


深入理解 go build 和 go install：
https://www.jianshu.com/p/3db831d9b553

初探 Go 的编译命令执行过程：
https://studygolang.com/articles/10572

package main;
 
import (
    "fmt"
)
 
func main() {
    //声明一个数组
    var a [3]int;
    a = [3]int{1, 2, 3};
    //声明并赋值
    var b [3]int = [3]int{1, 2, 3};
    //声明并赋值(省略类型)
    var c = [3]int{1, 2, 3};
    //声明并赋值简写
    d := [3]int{1, 2, 3};
 
    //GO中将数组长度作为数组类型的一部分
    //e与f是两个类型不同的变量，他们之间不能进行赋值操作
    var e [2]int;
    var f [3]int;
 
    //指定下标初始零值，将最后一个元素设置为1
    var g [20]int = [20]int{19: 1};
 
    //使用...让GO自动计算数组长度
    h := [...]int{1, 2, 3, 4, 5};
 
    //GO自动计算所需的数组长度，同变量g
    i := [...]int{19: 1};
 
    //数组的元素是指针，j数组的元素是指向int的指针
    aa := 1;
    bb := 2;
    j := [...]*int{&aa, &bb};
 
    //指向数组的指针
    k := [5]int{1, 2, 3, 4, 5};
    //m是一个指向数组的指针
    var m *[5]int = &k;
 
    //数组的比较
    n := [2]int{1, 2};
    o := [2]int{1, 2};
 
    //通过new返回一个指向数组的指针
    p := new([2]int);
    //也可以使用[]进行赋值
    p[0], p[1] = 1, 2;
 
    //多维数组，二行二列
    q := [2][2]int{{1, 2}, {3, 4}};
 
    //自动计算多维数组，必须是顶级
    r := [...][2]int{{1, 2}, {3, 4}, {5, 6}};
 
    fmt.Printf("%v\n%v\n%v\n%v\n%v\n%v\n%v\n%v\n%v\n%v\n%v\n", a, b, c, d, e, f, g, h, i, j, m);
    //进行数组比较
    fmt.Println(n == o);
    fmt.Println(p);
    fmt.Println(q);
    fmt.Println(r);
}





package commontest

import (
    "testing"
    "encoding/json"
)

func TestMap2Json(t *testing.T) {
    mapInstance := make(map[string]interface{})
    mapInstance["Name"] = "liang637210"
    mapInstance["Age"] = 28
    mapInstance["Address"] = "北京昌平区"

    jsonStr, err := json.Marshal(mapInstance)

    if err != nil {
        t.Fatal(err)
    }

    t.Logf("Map2Json 得到 json 字符串内容:%s", jsonStr)
}

    
golang判断key是否在map中
if _, ok := map[key]; ok {
    //存在
}



ab -n 100000 -c 100 "http://127.0.0.1:8801/qrcode/write-string?code=http%3A%2F%2Fwww.limishuxue.com"




siege -c 100 -t 60 http://127.0.0.1:8801/qrcode/write-string?code=http%3A%2F%2Fwww.limishuxue.com



http://service.limiketang.com/qr-code/write-string?code=http%3A%2F%2Fwww.limishuxue.com


siege -c 10 -t 60 http://service.limiketang.com/qr-code/write-string?code=http%3A%2F%2Fwww.limishuxue.com


siege -c 10 -t 5 http://service-go.limiketang.com/qrcode/write-string?code=http%3A%2F%2Fwww.limishuxue.com


{"errcode":40003,"errmsg":"invalid openid hint: [BrhDFa00914127]"}




[{"lesson_id":34009,"lesson_plan":1,"lesson_name":"体验课","lesson_status":0},{"lesson_id":29578,"lesson_plan":1,"lesson_name":"测试新交互","lesson_status":0},
{"lesson_id":27274,"lesson_plan":2,"lesson_name":"小可爱多测试七年级","lesson_status":0}
,{"lesson_id":30117,"lesson_plan":0,"lesson_name":"测试王大飞","lesson_status":3}]


27274



